//
//  RSWDBOperation+BasicData.m
//  RSW.IOS
//
//  Created by zhaiqiuqiu on 16/11/30.
//  Copyright © 2016年 com.xtion.crm. All rights reserved.
//

#import "RSWDBOperation+BasicData.h"

@implementation RSWDBOperation (BasicData)

-(XLGResult*)getMenuList
{
    __block NSInteger nResult = FALSE;
    __block id list = nil;
    XMSSQLiteHelper *sqlHelper = [[XMSSQLiteHelper alloc]initWithSQLiteHelper:[RSWDBOperation RSWDBOperationSQLite]];
    nResult = [sqlHelper runSelectSQL:@"select * from menuinfo where pid is null order by orderby" withCls:[MenuInfo class] completion:^(NSArray *arList)
               {
                   list = arList;
               }];
    
    return [XLGResult resultWithOutResult:nResult outObj:list];
}

-(XLGResult*)getSubMenuListByParentCode:(NSString*)pCode
{
    __block NSInteger nResult = FALSE;
    __block id list = nil;
    XMSSQLiteHelper *sqlHelper = [[XMSSQLiteHelper alloc]initWithSQLiteHelper:[RSWDBOperation RSWDBOperationSQLite]];
    nResult = [sqlHelper runSelectSQL:[NSString stringWithFormat:@"select * from menuinfo where pid in(select menuid from menuinfo where code = '%@') order by orderby", pCode] withCls:[MenuInfo class] completion:^(NSArray *arList)
               {
                   list = arList;
               }];
    
    return [XLGResult resultWithOutResult:nResult outObj:list];
}

-(XLGResult*)getWorkflowList
{
    __block NSInteger nResult = FALSE;
    __block id list = nil;
    XMSSQLiteHelper *sqlHelper = [[XMSSQLiteHelper alloc]initWithSQLiteHelper:[RSWDBOperation RSWDBOperationSQLite]];
    nResult = [sqlHelper runSelectSQL:@"select * from workflowinfo order by rownumber" withCls:[WorkflowInfo class] completion:^(NSArray *arList)
               {
                   list = arList;
               }];
    
    return [XLGResult resultWithOutResult:nResult outObj:list];
}

@end
